class Solution:
    def coinChange(self, coins, amount: int) -> int:
        if amount == 0:
            return 0
        f = [float('inf')] * (amount+1)
        f[0] = 0
        for c in coins:
            for j in range(c,amount+1):
                f[j] = min(f[j],f[j-c] + 1)
        return f[amount] if f[amount] != float('inf') else -1

# if __name__ == "__main__":
#     s = Solution()
#     res = s.coinChange([1,2,3],6)
#     print(res)
